package br.com.array.android.ma.view;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import br.com.array.android.ma.controller.ItemAlertaAdapter;
import br.com.array.android.ma.model.ItemAlertaModel;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by leonardo.neves on 19/05/2014.
 *
 */
public class FatorPotenciaFragment extends FragmentPage{

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        EnergiaReativaView view = new EnergiaReativaView(getActivity());

        final List<ItemAlertaModel> itens = new LinkedList<ItemAlertaModel>();
        itens.add(new ItemAlertaModel("14/07/2014", "22:25:06", "4"));
        itens.add(new ItemAlertaModel("15/07/2014", "09:00:00", "10"));
        itens.add(new ItemAlertaModel("16/07/2014", "15:55:17", "2"));
        itens.add(new ItemAlertaModel("17/07/2014", "17:55:17", "2"));
        itens.add(new ItemAlertaModel("18/07/2014", "05:55:17", "9"));
        itens.add(new ItemAlertaModel("19/07/2014", "10:55:17", "7"));
        final ItemAlertaAdapter adapter = new ItemAlertaAdapter(getActivity(), itens);
        view.setAdapertListView(adapter);

        view.setOnItemClickListenerView(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ItemAlertaModel model = (ItemAlertaModel) adapter.getItem(position);
                Intent intent = new Intent(getActivity(), AlarmeActivity.class);
                intent.putExtra(AlarmeActivity.TITULO, getTitulo());
                intent.putExtra(AlarmeActivity.MODELO, model);
                startActivity(intent);
            }
        });

        return view;
    }

    @Override
    public String getTitulo() {
        return "Fator potência";
    }
}
